home *** CD-ROM | disk | FTP | other *** search
/ Adventure Games / Adventure Games 1.iso / panic / panic.exe / panic.DXR / 00240.ls < prev    next >
Encoding:
Text File  |  1995-08-24  |  11.0 KB  |  371 lines

  1. global gSlowMachine, gDartSprite, gDartHandSprite, gHandAiming, gHandReleasing, gDart0, gDart1, gDart2, gDart3, gDart4, gDart5, gDart6, gDart7, gGreenBalloon, gGreenBalloonPopped, gOrangeBalloon, gOrangeBalloonPopped, gFortuneFrame, gFortuneCategory, gFortuneTeller, gOkaySprite, gFortuneCategorySprite, gMainMenuCursor, gNavigationCursor, gGeneralCursor, gForwardCursor, gBackwardCursor, gLeftCursor, gRightCursor, gScoreCursor, gAboutCursor, gHotCursor, gWaitCursor, gHot, gHotMask, cMainMenuCursor, cNavigationCursor, cGeneralCursor, cForwardCursor, cBackwardCursor, cLeftCursor, cRightCursor, cScoreCursor, cAboutCursor, cHotCursor, cWaitCursor, gBalloonSprite, gDeedBalloon, gDarts, gTokens, gTokenSprite, gStartDarts, gNextLocker
  2.  
  3. on startMovie
  4.   clearGlobals()
  5.   startMoviePrefs()
  6.   setProp(1, 48, "visibility", 1)
  7.   set the volume of sound 1 to 255
  8.   set the volume of sound 2 to 100
  9.   set gHot to the number of cast "Hot"
  10.   set gHotMask to the number of cast "HotMask"
  11.   set gSlowMachine to the machineType = 256
  12.   set gOkaySprite to 26
  13.   set gFortuneCategorySprite to 25
  14.   set gDartSprite to 26
  15.   set gDartHandSprite to 25
  16.   set gHandAiming to the number of cast "hand, aiming"
  17.   set gHandReleasing to the number of cast "hand, releasing"
  18.   set gDart0 to the number of cast "dart 0"
  19.   set gDart1 to the number of cast "dart 1"
  20.   set gDart2 to the number of cast "dart 2"
  21.   set gDart3 to the number of cast "dart 3"
  22.   set gDart4 to the number of cast "dart 4"
  23.   set gDart5 to the number of cast "dart 5"
  24.   set gDart6 to the number of cast "dart 6"
  25.   set gDart7 to the number of cast "dart 7"
  26.   set gGreenBalloon to the number of cast "green balloon"
  27.   set gGreenBalloonPopped to the number of cast "green balloon, popped"
  28.   set gOrangeBalloon to the number of cast "orange balloon"
  29.   set gOrangeBalloonPopped to the number of cast "orange balloon, popped"
  30.   set gFortuneTeller to label("Fortune Teller")
  31.   set cWaitCursor to the number of cast "Cursor, Wait"
  32.   set cHotCursor to the number of cast "Cursor, Hot"
  33.   set cAboutCursor to the number of cast "Cursor, About"
  34.   set cScoreCursor to the number of cast "Cursor, Score"
  35.   set cRightCursor to the number of cast "Cursor, Right"
  36.   set cLeftCursor to the number of cast "Cursor, Left"
  37.   set cBackwardCursor to the number of cast "Cursor, Backward"
  38.   set cForwardCursor to the number of cast "Cursor, Forward"
  39.   set cGeneralCursor to the number of cast "Cursor, General"
  40.   set cNavigationCursor to the number of cast "Cursor, Navigation"
  41.   set cMainMenuCursor to the number of cast "Cursor, Main Menu"
  42.   set gBalloonSprite to 2
  43.   set gDeedBalloon to random(16) + 4
  44.   set gDarts to 0
  45.   set gStartDarts to 0
  46.   set gTokens to 0
  47.   set gTokenSprite to 45
  48.   set gNextLocker to "L0"
  49.   puppetSound(0)
  50.   defineHotSpots([0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0])
  51.   when keyDown then checkKey
  52. end
  53.  
  54. on stopMovie
  55.   if the machineType <> 256 then
  56.     releaseRearWindow()
  57.   end if
  58.   set the text of cast "Query" to "?"
  59.   set the text of cast "Query2" to "?"
  60. end
  61.  
  62. on idle
  63.   checkHotSpots()
  64. end
  65.  
  66. on checkKey
  67.   set userKey to the key
  68.   set userKeyCode to the keyCode
  69.   if (userKey >= "0") and (userKey <= "9") then
  70.     if fortuneTeller() then
  71.       if the optionDown then
  72.         set the soundLevel to value(userKey)
  73.         dontPassEvent()
  74.         exit
  75.       else
  76.         if the castNum of sprite 10 = the number of cast "Query" then
  77.           appendText(userKey)
  78.           pass()
  79.           exit
  80.         end if
  81.       end if
  82.     else
  83.       set the soundLevel to value(userKey)
  84.       dontPassEvent()
  85.       exit
  86.     end if
  87.   end if
  88.   if fortuneTeller() then
  89.     if userKey = RETURN then
  90.       if the visible of sprite gOkaySprite = 1 then
  91.         dontPassEvent()
  92.         exit
  93.       else
  94.         if the frame >= label("Love") then
  95.           if pressButton(gOkaySprite - 1, 1) then
  96.             set the visible of sprite gOkaySprite to 1
  97.             set the visible of sprite (gOkaySprite + 1) to 1
  98.             go("Categories")
  99.           end if
  100.           dontPassEvent()
  101.           exit
  102.         else
  103.           if the frame >= label("Glow") then
  104.             pass()
  105.           else
  106.             if the frame >= label("Query") then
  107.               if pressButton(gOkaySprite - 1, 1) then
  108.                 setFortuneFrame()
  109.               end if
  110.               dontPassEvent()
  111.             else
  112.               pass()
  113.               exit
  114.             end if
  115.           end if
  116.         end if
  117.       end if
  118.     else
  119.       if the castNum of sprite 10 = the number of cast "Query" then
  120.         if (userKey >= "A") and (userKey <= "Z") then
  121.           appendText(userKey)
  122.           pass()
  123.           exit
  124.         end if
  125.         if (userKey = " ") or (userKey = "-") or (userKey = "/") or (userKey = ".") or (userKey = "!") or (userKey = "?") or (userKey = ":") or (userKey = ";") then
  126.           appendText(userKey)
  127.           pass()
  128.           exit
  129.         end if
  130.         if charToNum(userKey) = 8 then
  131.           deleteText(userKey)
  132.           pass()
  133.           exit
  134.         end if
  135.         dontPassEvent()
  136.       end if
  137.     end if
  138.   end if
  139. end
  140.  
  141. on appendText userKey
  142.   set query to the text of cast "Query"
  143.   if the number of chars in query < 60 then
  144.     set the text of cast "Query" to query & userKey
  145.     updateStage()
  146.   else
  147.     playSound("Locker")
  148.   end if
  149. end
  150.  
  151. on deleteText userKey
  152.   if charToNum(userKey) = 8 then
  153.     set query to the text of cast "Query"
  154.     delete char -30000 of query
  155.     set the text of cast "Query" to query
  156.     updateStage()
  157.   end if
  158. end
  159.  
  160. on programmersKey
  161.   return the shiftDown and the controlDown
  162. end
  163.  
  164. on fortuneTeller
  165.   return the frame >= gFortuneTeller
  166. end
  167.  
  168. on delayFor howLong, interrupt
  169.   set howLong to howLong + the timer
  170.   if voidp(interrupt) then
  171.     repeat while the timer < howLong
  172.       nothing()
  173.     end repeat
  174.   else
  175.     repeat while (the timer < howLong) and the mouseUp
  176.       nothing()
  177.     end repeat
  178.     if interrupt > 0 then
  179.       puppetTransition(0)
  180.       go(interrupt)
  181.     end if
  182.   end if
  183. end
  184.  
  185. on checkRange originalNumber, minValue, maxValue
  186.   if originalNumber < minValue then
  187.     set originalNumber to minValue
  188.   else
  189.     if originalNumber > maxValue then
  190.       set originalNumber to maxValue
  191.     end if
  192.   end if
  193.   return originalNumber
  194. end
  195.  
  196. on checkRangeWrap originalNumber, minValue, maxValue
  197.   if originalNumber < minValue then
  198.     set originalNumber to maxValue - (minValue - originalNumber) + 1
  199.   else
  200.     if originalNumber > maxValue then
  201.       set originalNumber to minValue + (originalNumber - maxValue) - 1
  202.     end if
  203.   end if
  204.   return originalNumber
  205. end
  206.  
  207. on setProp startSprite, stopSprite, whichProperty, whichValue
  208.   repeat with x = startSprite to stopSprite
  209.     do("set the " & whichProperty & " of sprite x=whichValue")
  210.   end repeat
  211. end
  212.  
  213. on legalButton whichSprite
  214.   repeat while the mouseDown
  215.     nothing()
  216.   end repeat
  217.   return 1
  218. end
  219.  
  220. on pressButton whichSprite, ignoreRollOver
  221.   repeat with x = 224 down to 217
  222.     set the foreColor of sprite whichSprite to x
  223.     updateStage()
  224.   end repeat
  225.   if programmersKey() then
  226.     set the loc of sprite whichSprite to point(the locH of sprite whichSprite + 1, the locV of sprite whichSprite + 1)
  227.     updateStage()
  228.     set the loc of sprite whichSprite to point(the locH of sprite whichSprite + 1, the locV of sprite whichSprite + 1)
  229.     updateStage()
  230.   end if
  231.   set delayFor to the timer + 20
  232.   repeat while the mouseDown or (the timer < delayFor)
  233.     nothing()
  234.   end repeat
  235.   if voidp(ignoreRollOver) then
  236.     set theResult to rollOver(whichSprite)
  237.   else
  238.     set theResult to ignoreRollOver
  239.   end if
  240.   repeat with x = 218 to 224
  241.     set the foreColor of sprite whichSprite to x
  242.     updateStage()
  243.     delay(5)
  244.   end repeat
  245.   set the foreColor of sprite whichSprite to 255
  246.   updateStage()
  247.   if programmersKey() then
  248.     set the loc of sprite whichSprite to point(the locH of sprite whichSprite - 1, the locV of sprite whichSprite - 1)
  249.     updateStage()
  250.     set the loc of sprite whichSprite to point(the locH of sprite whichSprite - 1, the locV of sprite whichSprite - 1)
  251.     updateStage()
  252.   end if
  253.   return theResult
  254. end
  255.  
  256. on setFortuneFrame
  257.   if gFortuneCategory > 0 then
  258.     set query to the text of cast "Query"
  259.     set queryWord1 to word 1 of query
  260.     if queryWord1 = EMPTY then
  261.       exit
  262.     else
  263.       if (queryWord1 = "Why") or (queryWord1 = "Why?") then
  264.         go("Why not?")
  265.         exit
  266.       else
  267.         if query contains "you" then
  268.           set youMatch to 0
  269.           repeat with x = 1 to the number of words in query
  270.             if (word x of query = "you") or (word x of query = "your") or (word x of query = "yourself") then
  271.               set youMatch to 1
  272.               exit repeat
  273.             end if
  274.           end repeat
  275.           if youMatch = 1 then
  276.             go("I'm not sure.")
  277.             exit
  278.           end if
  279.         end if
  280.       end if
  281.     end if
  282.     if not listp(gFortuneFrame) then
  283.       set gFortuneFrame to []
  284.     end if
  285.     set theCount to count(gFortuneFrame)
  286.     if programmersKey() then
  287.       if (theCount = 0) or (theCount < gFortuneCategory) then
  288.         set newFrame to random(2) + 7
  289.       else
  290.         set oldFrame to getAt(gFortuneFrame, gFortuneCategory)
  291.         if oldFrame = 0 then
  292.           set newFrame to random(2) + 7
  293.         else
  294.           if (oldFrame < 8) or (oldFrame > 9) then
  295.             set newFrame to 8
  296.           else
  297.             set newFrame to oldFrame + 1
  298.           end if
  299.         end if
  300.       end if
  301.       set whichCategory to getAt(["Love", "Career", "Family", "Fame"], gFortuneCategory)
  302.     else
  303.       if the number of cast "FT1.5" < 1 then
  304.         set newFrame to random(4)
  305.       else
  306.         set newFrame to random(7)
  307.       end if
  308.       set whichCategory to getAt(["Love", "Career", "Fame", "Family"], gFortuneCategory)
  309.     end if
  310.     setAt(gFortuneFrame, gFortuneCategory, newFrame)
  311.     set whichFrame to label(whichCategory) + newFrame - 1
  312.     if whichFrame > 0 then
  313.       go(label(whichCategory) + newFrame - 1)
  314.     else
  315.       nothing()
  316.     end if
  317.   end if
  318. end
  319.  
  320. on defineHotSpots cuMainMenu, cuNavigation, cuGeneral, cuForward, cuBackward, cuLeft, cuRight, cuScore, cuAbout, cuHot, cuWait
  321.   set gMainMenuCursor to cuMainMenu
  322.   set gNavigationCursor to cuNavigation
  323.   set gGeneralCursor to cuGeneral
  324.   set gForwardCursor to cuForward
  325.   set gBackwardCursor to cuBackward
  326.   set gLeftCursor to cuLeft
  327.   set gRightCursor to cuRight
  328.   set gScoreCursor to cuScore
  329.   set gAboutCursor to cuAbout
  330.   set gHotCursor to cuHot
  331.   set gWaitCursor to cuWait
  332.   setProp(1, 48, "visibility", 1)
  333. end
  334.  
  335. on checkHotSpots
  336.   if checkHotSpot(gHotCursor, cHotCursor) then
  337.     cursor([gHot, gHotMask])
  338.     exit
  339.   end if
  340.   cursor(-1)
  341. end
  342.  
  343. on checkHotSpot whichSprites, whichCursor
  344.   set theResult to 0
  345.   set startSprite to getAt(whichSprites, 1)
  346.   set stopSprite to getAt(whichSprites, 2)
  347.   if startSprite > 0 then
  348.     repeat with x = stopSprite down to startSprite
  349.       if the type of sprite x > 0 then
  350.         if rollOver(x) then
  351.           set theResult to 1
  352.           exit repeat
  353.         end if
  354.       end if
  355.     end repeat
  356.   end if
  357.   return theResult
  358. end
  359.  
  360. on playSound whichSound
  361.   set whichCast to the number of cast whichSound
  362.   if whichCast > 0 then
  363.     puppetSound(whichSound)
  364.     updateStage()
  365.     repeat while the soundBusy of 1
  366.       updateStage()
  367.     end repeat
  368.     puppetSound(0)
  369.   end if
  370. end
  371.